const mongoose = require("./db");
// 订单
const orderlist = new mongoose.Schema({
  number: Number, //编号
  orderNumber: Number, //订单号
  SubmitTime: String, //提交时间
  UserAccount: String, //用户账号
  commodity: Array, //订单项列表
  receiverCity: String, //收货人城市
  receiverName: String, //收货人姓名
  receiverPhone: String, //收货人电话
  receiverPostCode: String, //邮政编码
  payType: Number, //支付类型 1.支付宝 2.微信 3.未支付
  status: Number, //状态 1.待付款 2.待发货 3.已发货 4.已完成 5.已关闭
  sourceType: Number, //订单来源 1.PC订单 2.app订单
  orderType: Number, //订单类型 1.正常订单 2.秒杀订单
  freightAmount: Number, //运费
  payAmount: Number, //实付金额
  historyList: [{ type: mongoose.Schema.Types.ObjectId, ref: "History" }],
  chk: String, //是否选中
});
//商品
const commoditySchema = new mongoose.Schema({
  productName: String, //商品名称
  productPrice: Number, //商品价格
  productQuantity: Number, //商品数量
  productPic: String, //商品图片
  productcolor: String, //商品颜色
  productSize: String, //商品尺码
  productBrand: String, //商品品牌
});
// 操作信息
const historyList = mongoose.Schema({
  createTime: String, //操作时间
  id: Number, //编号
  note: String, //备注
  operateMan: String, //操作人
  orderStatus: Number, //订单状态
  payment: Number, //支付状态
});
// 退货
const ReturnsSchema = mongoose.Schema({
    handleTime: Date,//处理时间
    handleNote: String,//收货备注
    handleMan: String,//处理人员
    
    receiveMan: String,//收货人员
    receiveNote: String,//收货备注
    receiveTime: Date,//收货备注
    
    returnAmount:String,//确认退款金额
    productRealPrice:String,//订单金额
    returnName:String,//收货人姓名+联系人
    addressName:String,//收货地点
    province:String,//省份地区
    detailAddress:String,//详细地址
    phone:Number,//联系电话

    id: Number, //服务单号
    status: Number,//申请状态 1.待处理 2.退货中 3.已完成 4.已拒绝
    orderSn: Number,//订单编号
    createTime: Date,//申请时间
    memberUsername:String,// 用户账号
    returnPhone:String,// 联系电话
    reason:String,// 退货原因
    description:String,// 问题描述
    productPic:String,// 商品图片
    
    productName:String,// 商品名称
    productColor: String,//颜色
    productSize: String,//尺码
    productcount: Number,//数量
    
})
const historyListModel = mongoose.model("historyList", historyList, "historyList")
const commodityModel = mongoose.model("commodity", commoditySchema, "commodity")
const orderModel = mongoose.model("order", orderlist, "order")

const ReturnsModel = mongoose.model("returns", ReturnsSchema, "returns"); //退货订单
module.exports = { commodityModel, orderModel, historyListModel, ReturnsModel };
